home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 20 / Cream of the Crop 20 (Terry Blount) (1996).iso / os2 / fm2utils.zip / open.cmd < prev    next >
OS/2 REXX Batch file  |  1996-03-30  |  2KB  |  95 lines

  1. /* OPEN.CMD -- opens a WPS object */
  2.  
  3. /* load rexx utility functions */
  4.  
  5. call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  6. call SysLoadFuncs
  7.  
  8. view = 'DEFAULT'
  9. quiet = ''
  10. name = ''
  11.  
  12. /* parse command line */
  13. call CLI arg(1)
  14.  
  15. /* analyze arguments, set switches and vars */
  16. do i = 1 to argv.0
  17.   if left(argv.i,1) = '/' then
  18.   do
  19.     if substr(argv.i,2,1) = 'v' then
  20.     do
  21.       view = right(argv.i,length(argv.i) - 2)
  22.     end
  23.     else if substr(argv.i,2,1) = 'V' then
  24.     do
  25.       view = right(argv.i,length(argv.i) - 2)
  26.     end
  27.     else if substr(argv.i,2,1) = 's' then
  28.     do
  29.       quiet = 'quiet'
  30.     end
  31.     else if substr(argv.i,2,1) = 'S' then
  32.     do
  33.       quiet = 'quiet'
  34.     end
  35.     else if substr(argv.i,2,1) = '?' then
  36.     do
  37.       signal giveHelp
  38.     end
  39.   end
  40.   else name = argv.i
  41. end
  42.  
  43. /* do the dirty deed */
  44. if name \= '' then
  45. do
  46.   if quiet = '' then
  47.   do
  48.     say ' Opening "'name'"'
  49.     say '  View = "'view'"'
  50.   end
  51.  
  52.   setup = 'OPEN='view
  53.   rc = SysSetObjectData(name,setup)
  54.  
  55.   if quiet = '' then
  56.   do
  57.     if rc = 0 then say 'Open failed.'
  58.     if rc \= 0 then say 'Open succeeded.'
  59.   end
  60. end
  61. else signal giveHelp
  62. exit
  63.  
  64. /*
  65.  * Usage help
  66.  */
  67. giveHelp:
  68.  
  69. say 'Usage:  OPEN <object name or id> [/v<view>] [/silent]'
  70. say ''
  71. say ' <object name or id> is the full qualified pathname of a file'
  72. say '                     system object or an id like <WP_DESKTOP>'
  73. say ' <view> can be ICON, TREE, DETAILS, SETTINGS, etc. (defaults to DEFAULT)'
  74. say '  Examples:  OPEN "<WP_CLOCK>"  (Note quotes around object id!)'
  75. say '             OPEN C:\DESKTOP\MYFOLDER /vICON /s'
  76. say ''
  77. say 'Hector wuz here.'
  78. exit
  79.  
  80. /*
  81.  * Command Line Interpreter
  82.  */
  83. CLI: procedure expose argv.
  84.  
  85. args = arg(1)
  86. argv.0 = 0
  87. do i = 1 while args >< ''
  88.   argv.0 = i
  89.  parse value strip(args,'B') with argv.i args
  90.   if left(argv.i, 1) = '"' then
  91.     parse value argv.i args with '"' argv.i '"' args
  92. end
  93. return
  94.  
  95.